<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button id="btn">跳转</button>
</body>
<script>
  // 颜色 
  // 单词:  red  blue green  pink 
  // 16进制: #ffffff
  // rgba:   rgba(255,255,255,1);

  // 0-f   => 随机一个字符  => 重复6次
  document.bgColor = randColor();

  function randColor() {
    var str = "0123456789abcdef";
    var colorStr = "#";
    for (var i = 0; i < 6; i++) {
      var index = Math.floor(Math.random() * str.length); // [0,length-1]
      var char = str.charAt(index);
      // console.log(char);
      colorStr += char;
    }
    // console.log(colorStr);
    // document.bgColor = colorStr;
    return colorStr;
  }

  function randColor() {
    return `rgba(${randNum()},${randNum()},${randNum()},1)`;
  }

  function randNum() {
    return Math.round(Math.random() * 255);
  }


  btn.onclick = function () {
    // 127.0.0.1 localhost 
    // location.href = "http://127.0.0.1:5500/day24/html/login.html";
    location.href = "login.html";
  }
</script>

</html>